package com.cslc.provider;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.alibaba.csp.sentinel.init.InitExecutor;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;

import java.io.IOException;
import java.util.Collections;

/**
 * Hello world!
 */
public class ProviderApp {
    
    //private static final String RES_KEY = "xinQing.provider.service.ProviderService:say(java.lang.String)";
    //private static final String INTERFACE_RES_KEY = "com.alibaba.csp.sentinel.demo.dubbo.FooService";
    
    @SuppressWarnings("resource")
    public static void main(String[] args) throws IOException {
	
        InitExecutor.doInit();
        //initFlowRule();
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"dubbo-provider.xml"});
        context.start();
        System.out.println("provider app run ");
        System.in.read(); // 按任意键退出
        
    }
    
//    private static void initFlowRule() {
//        FlowRule flowRule = new FlowRule();
//        flowRule.setResource(RES_KEY);
//        flowRule.setCount(10);
//        flowRule.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_RATIO);
//        flowRule.setLimitApp("default");
//        flowRule.setWarmUpPeriodSec(100);
//        FlowRuleManager.loadRules(Collections.singletonList(flowRule));
//    }
}
